package com.ld.control.business.variable.controller;


import com.baomidou.mybatisplus.core.metadata.IPage;
import com.ld.control.business.variable.service.VariableExampleService;
import com.ld.control.business.variable.vo.resp.VariableExampleResp;
import com.ld.control.business.variable.vo.resp.VariableRespVo;
import com.ld.control.common.ResultResponse;
import com.ld.control.common.vo.GeneratePageListVo;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 * 变量实例表 前端控制器
 * </p>
 *
 * @author wangfeng
 * @since 2024-04-23
 */
@Slf4j
@Tag(name = "任务变量实例相关接口")
@RestController
public class VariableExampleController {

    @Autowired
    private VariableExampleService variableExampleService;

    @GetMapping("/api/centralControl/variableExample/getPageList")
    @Operation(summary = "任务变量实例列表")
    public ResultResponse<GeneratePageListVo<VariableExampleResp>> getPageList(
            @RequestParam(required = false) String name,
            @RequestParam(required = false) String taskExampleCode,
            @RequestParam(required = false) Long taskSubExampleId,
            @RequestParam(required = false) Long variableId,
            @RequestParam(required = false, defaultValue = "1") Integer current,
            @RequestParam(required = false, defaultValue = "10") Integer size
    ){
        IPage<VariableExampleResp> pageList = variableExampleService.getPageList(name, taskExampleCode,
                taskSubExampleId, variableId, current, size);
        return ResultResponse.success(new GeneratePageListVo<>(pageList));
    }

    @GetMapping("/api/centralControl/variableExample/getById")
    @Operation(summary = "变量实例详细信息")
    public ResultResponse<VariableExampleResp> getById(
            @RequestParam Long id
    ){
        VariableExampleResp variableExampleResp = variableExampleService.getById(id);
        return ResultResponse.success(variableExampleResp);
    }
}

